#!/usr/bin/python
import sys
import os
import time

placeHolder = '#REPLACE#'

def updateFromTemplate(label, template):
	template_file = open(template)
	schema_out_name = template_file.name.replace('template', label)
	schema_file = open(schema_out_name,'w')
	for line in template_file:
		schema_file.write(line.replace(placeHolder, label))
	schema_file.close()
	template_file.close()
	print "Done creating schema file from template %s" % time.ctime()


if __name__ == "__main__":
	if (len(sys.argv) != 3):
		print 'Proper usage is python createSchemaFromTemplate.py schema_label schema_sql_template_file'	
	label = sys.argv[1]
	template = sys.argv[2]
	updateFromTemplate(label, template)


